package com.hdkj.eduservice.controller.front;

import com.hdkj.commonutils.R;
import com.hdkj.eduservice.entity.EduCourse;
import com.hdkj.eduservice.entity.EduTeacher;
import com.hdkj.eduservice.service.EduCourseService;
import com.hdkj.eduservice.service.EduTeacherService;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;

import java.util.List;

@RestController
@RequestMapping("/eduservice/frontindex")
//@CrossOrigin
public class indexfrontcontroller {
    @Autowired
    private EduCourseService courseService;

    @Autowired
    private EduTeacherService teacherService;

    //查询首页8条课程记录，4条名师记录
    @GetMapping("index")
    public R index() throws InterruptedException {
        //查询首页8条课程记录
        //整合redis

                List<EduCourse> courseList= courseService.getcourselist();

//        QueryWrapper<EduCourse> courseWrapper=new QueryWrapper<>();
//        courseWrapper.orderByDesc("id");
//        courseWrapper.last("limit 8");
//        List<EduCourse> eduCourseList = courseService.list(courseWrapper);
        //4条名师记录
        List<EduTeacher> teacherList=teacherService.getteacherlist();
//        QueryWrapper<EduTeacher> teacherWrapper=new QueryWrapper<>();
//        teacherWrapper.orderByDesc("id");
//        teacherWrapper.last("limit 4");
//        List<EduTeacher> eduTeacherList = teacherService.list(teacherWrapper);
//
    return R.ok().data("eduCourseList",courseList).data("eduTeacherList",teacherList);
    }

}
